<?php

namespace app\admin\model;

use think\Model;

class Trade extends Model
{
    // 表名
    protected $name = 'currency_trade';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'status_text'
    ];

    public function getStatusList()
    {
        return ['1' => __('可用'),'2' => __('不可用')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : $data['status'];
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    







    public function currency()
    {
        return $this->belongsTo('Currency', 'currency_id', 'currency_id', [], 'LEFT')->setEagerlyType(0);
    }
    public function currencyleger()
    {
        return $this->belongsTo('Currency', 'currency_leger_id', 'currency_id', [], 'LEFT')->setEagerlyType(0);
    }
}
